package com.tz.zczc.web.controller;

import com.tz.zczc.domain.model.common.Response;
import com.tz.zczc.domain.model.entity.Keywords;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:Mark
 * @Description:
 * @Date: Created on 16:56 2018-12-5
 * @Modify by:
 */
@RestController
@RequestMapping("/zczc/keywords")
@Api(value = "【搜素关键词维护接口】搜素关键词维护接口",tags = "搜素关键词维护接口")
@Validated
public interface KeywordsController {

  @ApiOperation(value ="增加一条搜索记录",notes="增加搜索记录" )
  @PostMapping("/addRecords")
  Response addRecords(HttpServletRequest request, HttpServletResponse response,
      @ApiParam(required = true,name = "keywords",value = "搜索的内容")
      @RequestParam(value = "keywords" ,required = true) String keywords);


  @ApiOperation(value = "通过id来删除记录",notes = "逻辑删除")
  @DeleteMapping("/deleteRecordsByIds")
  Response delRecordsByIds(HttpServletRequest request,HttpServletResponse response,
     @NotEmpty(message = "传入的id不能为空") @RequestBody List<String> ids);

  @ApiOperation(value = "分页查询所有记录",notes = "传入页大小、页码进行分页查询")
  @GetMapping("/getRecordsByPage")
  Response getRecordsByPage(HttpServletRequest request,HttpServletResponse response,
      @ApiParam(required = false,name="pageSize",value = "页大小") @RequestParam(required = false ,defaultValue ="20",value = "pageSize")
      @Min(value =1,message = "页大小不能小于1") Integer pageSize,
      @ApiParam(required = false,name = "pageNum",value = "页码") @RequestParam(required = false,value = "pageNum",defaultValue = "1")
      @Min(value = 1,message = "页码不能小于1") Integer pageNum
  );

  @ApiOperation(value = "根据id值选择性的修改内容",notes = "根据id值选择性的修改内容")
  @PutMapping("/updateRecordsSelective")
  Response updateRecordsSelective(HttpServletRequest request,HttpServletResponse response,
      @ApiParam(required = true,name = "keywords",value = "要修改的对象")
      @RequestBody Keywords keywords
      );

}
